import logging

from config import BASE_HOST


class OpenAccountApi:

    def __init__(self, ses):
        self.ses = ses

    # 实名认证接口
    def realname(self, realname_v, cardId_v):
        # 实现接口请求，获取响应结果
        url = BASE_HOST + '/member/realname/approverealname'
        data_id = {'realname': realname_v,
                   'card_id': cardId_v}
        resp = self.ses.post(url=url, data=data_id, files={'a': 'b'})
        # 将响应体的数据打印到日志
        logging.info(f'实名认证接口返回的响应体数据：{resp.json()}')
        # 封装方法的返回
        return resp

    # 开户接口
    def open_account(self):
        url = BASE_HOST + '/trust/trust/register'
        resp = self.ses.post(url=url)
        logging.info(f'开户接口的响应体数据：{resp.json()}')
        return resp

    # 第三方开户接口
    def third_open_account(self, url, form_dict):
        resp = self.ses.post(url=url,data=form_dict)
        logging.info(f'第三方开户接口的响应体数据：{resp.text}')
        return resp

